#include <stdio.h>
#include <time.h>
// #include <x86intrin.h>

void prefetch_example() {
    int arr[100000];
    for (int i = 0; i < 100000; i++) {
        arr[i] = i;
    }
    

    for (int i = 0;i < 100000;i+=100)
    {

        int *arry = &arr[0] + i;

        for (int k = 0; k < 8; k++) {
            __builtin_prefetch(&arry[k], 0);
        }

        for (int p = 0;p < 100;p++)
        {
            arry[p] * arry[p] * arry[p];
        }
    }

    // for (int i = 0;i < 100000;i++)
    // {
    //     arr[i] * arr[i] * arr[i];
    // }
    

    
}

int main() {
    clock_t start_time = clock();
    prefetch_example();
    clock_t end_time = clock();
    double elapsed_time = (double)(end_time - start_time) / CLOCKS_PER_SEC;
    printf("处理延时： %f 秒\n", elapsed_time);
    return 0;
}
